.class final Lcom/tendcloud/tenddata/cr;
.super Ljava/lang/Object;


# static fields
.field private static final a:Ljava/lang/String; = "PushLog"

.field private static b:Lcom/tendcloud/tenddata/cr$a; = null

.field private static final c:Ljava/lang/String; = "create table IF NOT EXISTS kv (k text primary key, v text)"

.field private static final d:Ljava/lang/String; = "insert into kv values(?,?)"

.field private static final e:Ljava/lang/String; = "update kv set v=? where k=?"

.field private static final f:Ljava/lang/String; = "delete from kv where k=?"

.field private static final g:Ljava/lang/String; = "select k from kv where k like ?"

.field private static final h:Ljava/lang/String; = "select v from kv where k like ?"

.field private static final i:Ljava/lang/String; = "select k from kv where v=?"

.field private static final j:Ljava/lang/String; = "select v from kv where k=?"

.field private static final k:Ljava/lang/String; = "create table IF NOT EXISTS msg (msg_id text primary key, ct INTEGER)"

.field private static final l:Ljava/lang/String; = "insert into msg values(?,?)"

.field private static final m:Ljava/lang/String; = "update msg set ct=? where msg_id=?"

.field private static final n:Ljava/lang/String; = "delete from msg where ct<=?"

.field private static final o:Ljava/lang/String; = "select ct from msg where msg_id=?"

.field private static final p:Ljava/lang/String; = "select ct from msg order by ct asc limit 1 offset 100"

.field private static final q:Ljava/lang/String; = "select count(*) from msg"


# direct methods
.method constructor <init>()V
    .locals 0

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method static a(Ljava/lang/String;)Ljava/util/List;
    .locals 5

    const/4 v4, 0x0

    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    if-eqz p0, :cond_1

    invoke-static {}, Lcom/tendcloud/tenddata/cr;->d()Lcom/tendcloud/tenddata/cr$a;

    move-result-object v1

    invoke-virtual {v1}, Lcom/tendcloud/tenddata/cr$a;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    const-string v2, "select k from kv where k like ?"

    const/4 v3, 0x1

    new-array v3, v3, [Ljava/lang/String;

    aput-object p0, v3, v4

    invoke-virtual {v1, v2, v3}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v1

    invoke-interface {v1}, Landroid/database/Cursor;->moveToFirst()Z

    move-result v2

    if-eqz v2, :cond_0

    :goto_0
    invoke-interface {v1}, Landroid/database/Cursor;->isAfterLast()Z

    move-result v2

    if-nez v2, :cond_0

    invoke-interface {v1, v4}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v2

    invoke-interface {v0, v2}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    invoke-interface {v1}, Landroid/database/Cursor;->moveToNext()Z

    goto :goto_0

    :cond_0
    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    :cond_1
    return-object v0
.end method

.method static a()V
    .locals 1

    invoke-static {}, Lcom/tendcloud/tenddata/cr;->d()Lcom/tendcloud/tenddata/cr$a;

    move-result-object v0

    invoke-virtual {v0}, Lcom/tendcloud/tenddata/cr$a;->close()V

    return-void
.end method

.method static declared-synchronized a(Landroid/content/Context;)V
    .locals 2

    const-class v1, Lcom/tendcloud/tenddata/cr;

    monitor-enter v1

    if-eqz p0, :cond_0

    :try_start_0
    sget-object v0, Lcom/tendcloud/tenddata/cr;->b:Lcom/tendcloud/tenddata/cr$a;

    if-nez v0, :cond_0

    new-instance v0, Lcom/tendcloud/tenddata/cr$a;

    invoke-direct {v0, p0}, Lcom/tendcloud/tenddata/cr$a;-><init>(Landroid/content/Context;)V

    sput-object v0, Lcom/tendcloud/tenddata/cr;->b:Lcom/tendcloud/tenddata/cr$a;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    :cond_0
    monitor-exit v1

    return-void

    :catchall_0
    move-exception v0

    monitor-exit v1

    throw v0
.end method

.method static a(Ljava/lang/String;Ljava/lang/String;)Z
    .locals 6

    const/4 v0, 0x1

    const/4 v1, 0x0

    if-eqz p0, :cond_1

    :try_start_0
    invoke-static {p0}, Lcom/tendcloud/tenddata/cr;->e(Ljava/lang/String;)Z

    move-result v2

    if-eqz v2, :cond_0

    invoke-static {}, Lcom/tendcloud/tenddata/cr;->d()Lcom/tendcloud/tenddata/cr$a;

    move-result-object v2

    invoke-virtual {v2}, Lcom/tendcloud/tenddata/cr$a;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v2

    const-string v3, "update kv set v=? where k=?"

    const/4 v4, 0x2

    new-array v4, v4, [Ljava/lang/String;

    const/4 v5, 0x0

    aput-object p1, v4, v5

    const/4 v5, 0x1

    aput-object p0, v4, v5

    invoke-virtual {v2, v3, v4}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;[Ljava/lang/Object;)V

    :goto_0
    return v0

    :cond_0
    invoke-static {}, Lcom/tendcloud/tenddata/cr;->d()Lcom/tendcloud/tenddata/cr$a;

    move-result-object v2

    invoke-virtual {v2}, Lcom/tendcloud/tenddata/cr$a;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v2

    const-string v3, "insert into kv values(?,?)"

    const/4 v4, 0x2

    new-array v4, v4, [Ljava/lang/String;

    const/4 v5, 0x0

    aput-object p0, v4, v5

    const/4 v5, 0x1

    aput-object p1, v4, v5

    invoke-virtual {v2, v3, v4}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;[Ljava/lang/Object;)V
    :try_end_0
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    :catch_0
    move-exception v0

    const-string v2, "PushLog"

    invoke-virtual {v0}, Ljava/lang/Throwable;->getMessage()Ljava/lang/String;

    move-result-object v0

    invoke-static {v2, v0}, Lcom/tendcloud/tenddata/cs;->e(Ljava/lang/String;Ljava/lang/String;)V

    :cond_1
    move v0, v1

    goto :goto_0
.end method

.method static b()J
    .locals 6

    const-wide/16 v2, 0x0

    :try_start_0
    invoke-static {}, Lcom/tendcloud/tenddata/cr;->d()Lcom/tendcloud/tenddata/cr$a;

    move-result-object v0

    invoke-virtual {v0}, Lcom/tendcloud/tenddata/cr$a;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    const-string v1, "select count(*) from msg"

    const/4 v4, 0x0

    invoke-virtual {v0, v1, v4}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v4

    invoke-interface {v4}, Landroid/database/Cursor;->moveToFirst()Z

    const/4 v0, 0x0

    invoke-interface {v4, v0}, Landroid/database/Cursor;->getLong(I)J
    :try_end_0
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_0

    move-result-wide v0

    :try_start_1
    invoke-interface {v4}, Landroid/database/Cursor;->close()V
    :try_end_1
    .catch Ljava/lang/Throwable; {:try_start_1 .. :try_end_1} :catch_1

    :goto_0
    return-wide v0

    :catch_0
    move-exception v0

    move-object v5, v0

    move-wide v0, v2

    move-object v2, v5

    :goto_1
    const-string v3, "PushLog"

    invoke-virtual {v2}, Ljava/lang/Throwable;->getMessage()Ljava/lang/String;

    move-result-object v2

    invoke-static {v3, v2}, Lcom/tendcloud/tenddata/cs;->e(Ljava/lang/String;Ljava/lang/String;)V

    goto :goto_0

    :catch_1
    move-exception v2

    goto :goto_1
.end method

.method static b(Ljava/lang/String;)Ljava/util/List;
    .locals 5

    const/4 v4, 0x0

    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    if-eqz p0, :cond_1

    invoke-static {}, Lcom/tendcloud/tenddata/cr;->d()Lcom/tendcloud/tenddata/cr$a;

    move-result-object v1

    invoke-virtual {v1}, Lcom/tendcloud/tenddata/cr$a;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    const-string v2, "select k from kv where v=?"

    const/4 v3, 0x1

    new-array v3, v3, [Ljava/lang/String;

    aput-object p0, v3, v4

    invoke-virtual {v1, v2, v3}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v1

    invoke-interface {v1}, Landroid/database/Cursor;->moveToFirst()Z

    move-result v2

    if-eqz v2, :cond_0

    :goto_0
    invoke-interface {v1}, Landroid/database/Cursor;->isAfterLast()Z

    move-result v2

    if-nez v2, :cond_0

    invoke-interface {v1, v4}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v2

    invoke-interface {v0, v2}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    invoke-interface {v1}, Landroid/database/Cursor;->moveToNext()Z

    goto :goto_0

    :cond_0
    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    :cond_1
    return-object v0
.end method

.method static c(Ljava/lang/String;)Ljava/util/List;
    .locals 5

    const/4 v4, 0x0

    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    if-eqz p0, :cond_1

    invoke-static {}, Lcom/tendcloud/tenddata/cr;->d()Lcom/tendcloud/tenddata/cr$a;

    move-result-object v1

    invoke-virtual {v1}, Lcom/tendcloud/tenddata/cr$a;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    const-string v2, "select v from kv where k like ?"

    const/4 v3, 0x1

    new-array v3, v3, [Ljava/lang/String;

    aput-object p0, v3, v4

    invoke-virtual {v1, v2, v3}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v1

    invoke-interface {v1}, Landroid/database/Cursor;->moveToFirst()Z

    move-result v2

    if-eqz v2, :cond_0

    :goto_0
    invoke-interface {v1}, Landroid/database/Cursor;->isAfterLast()Z

    move-result v2

    if-nez v2, :cond_0

    invoke-interface {v1, v4}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v2

    invoke-interface {v0, v2}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    invoke-interface {v1}, Landroid/database/Cursor;->moveToNext()Z

    goto :goto_0

    :cond_0
    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    :cond_1
    return-object v0
.end method

.method static c()V
    .locals 6

    const-wide/16 v2, 0x0

    const/4 v5, 0x0

    invoke-static {}, Lcom/tendcloud/tenddata/cr;->d()Lcom/tendcloud/tenddata/cr$a;

    move-result-object v0

    invoke-virtual {v0}, Lcom/tendcloud/tenddata/cr$a;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    const-string v1, "select ct from msg order by ct asc limit 1 offset 100"

    const/4 v4, 0x0

    invoke-virtual {v0, v1, v4}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v4

    invoke-interface {v4}, Landroid/database/Cursor;->moveToFirst()Z

    move-result v0

    if-eqz v0, :cond_1

    invoke-interface {v4, v5}, Landroid/database/Cursor;->getLong(I)J

    move-result-wide v0

    invoke-interface {v4}, Landroid/database/Cursor;->close()V

    :goto_0
    cmp-long v2, v0, v2

    if-lez v2, :cond_0

    invoke-static {}, Lcom/tendcloud/tenddata/cr;->d()Lcom/tendcloud/tenddata/cr$a;

    move-result-object v2

    invoke-virtual {v2}, Lcom/tendcloud/tenddata/cr$a;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v2

    const-string v3, "delete from msg where ct<=?"

    const/4 v4, 0x1

    new-array v4, v4, [Ljava/lang/Object;

    invoke-static {v0, v1}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v0

    aput-object v0, v4, v5

    invoke-virtual {v2, v3, v4}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;[Ljava/lang/Object;)V

    :cond_0
    return-void

    :cond_1
    move-wide v0, v2

    goto :goto_0
.end method

.method private static d()Lcom/tendcloud/tenddata/cr$a;
    .locals 2

    sget-object v0, Lcom/tendcloud/tenddata/cr;->b:Lcom/tendcloud/tenddata/cr$a;

    if-nez v0, :cond_0

    const-string v0, "PushLog"

    const-string v1, "Err: invoke PushManager.startPushService to init push sdk"

    invoke-static {v0, v1}, Lcom/tendcloud/tenddata/cs;->e(Ljava/lang/String;Ljava/lang/String;)V

    :cond_0
    sget-object v0, Lcom/tendcloud/tenddata/cr;->b:Lcom/tendcloud/tenddata/cr$a;

    return-object v0
.end method

.method static d(Ljava/lang/String;)Ljava/lang/String;
    .locals 5

    const/4 v4, 0x0

    const/4 v0, 0x0

    if-eqz p0, :cond_1

    invoke-static {}, Lcom/tendcloud/tenddata/cr;->d()Lcom/tendcloud/tenddata/cr$a;

    move-result-object v1

    invoke-virtual {v1}, Lcom/tendcloud/tenddata/cr$a;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    const-string v2, "select v from kv where k=?"

    const/4 v3, 0x1

    new-array v3, v3, [Ljava/lang/String;

    aput-object p0, v3, v4

    invoke-virtual {v1, v2, v3}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v1

    invoke-interface {v1}, Landroid/database/Cursor;->moveToFirst()Z

    move-result v2

    if-eqz v2, :cond_0

    invoke-interface {v1, v4}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v0

    :cond_0
    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    :cond_1
    return-object v0
.end method

.method static e(Ljava/lang/String;)Z
    .locals 4

    invoke-static {}, Lcom/tendcloud/tenddata/cr;->d()Lcom/tendcloud/tenddata/cr$a;

    move-result-object v0

    invoke-virtual {v0}, Lcom/tendcloud/tenddata/cr$a;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    const-string v1, "select v from kv where k=?"

    const/4 v2, 0x1

    new-array v2, v2, [Ljava/lang/String;

    const/4 v3, 0x0

    aput-object p0, v2, v3

    invoke-virtual {v0, v1, v2}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v0

    invoke-interface {v0}, Landroid/database/Cursor;->moveToFirst()Z

    move-result v1

    invoke-interface {v0}, Landroid/database/Cursor;->close()V

    return v1
.end method

.method static f(Ljava/lang/String;)V
    .locals 4

    invoke-static {}, Lcom/tendcloud/tenddata/cr;->d()Lcom/tendcloud/tenddata/cr$a;

    move-result-object v0

    invoke-virtual {v0}, Lcom/tendcloud/tenddata/cr$a;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    const-string v1, "delete from kv where k=?"

    const/4 v2, 0x1

    new-array v2, v2, [Ljava/lang/String;

    const/4 v3, 0x0

    aput-object p0, v2, v3

    invoke-virtual {v0, v1, v2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;[Ljava/lang/Object;)V

    return-void
.end method

.method static g(Ljava/lang/String;)V
    .locals 2

    if-eqz p0, :cond_0

    invoke-static {p0}, Lcom/tendcloud/tenddata/cr;->a(Ljava/lang/String;)Ljava/util/List;

    move-result-object v0

    invoke-interface {v0}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v1

    :goto_0
    invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z

    move-result v0

    if-eqz v0, :cond_0

    invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/lang/String;

    invoke-static {v0}, Lcom/tendcloud/tenddata/cr;->f(Ljava/lang/String;)V

    goto :goto_0

    :cond_0
    return-void
.end method

.method static h(Ljava/lang/String;)Z
    .locals 8

    const/4 v0, 0x1

    const/4 v1, 0x0

    if-eqz p0, :cond_1

    invoke-static {}, Lcom/tendcloud/tenddata/cr;->b()J

    move-result-wide v2

    const-wide/16 v4, 0x3e8

    cmp-long v2, v2, v4

    if-ltz v2, :cond_0

    invoke-static {}, Lcom/tendcloud/tenddata/cr;->c()V

    :cond_0
    :try_start_0
    invoke-static {}, Lcom/tendcloud/tenddata/cr;->d()Lcom/tendcloud/tenddata/cr$a;

    move-result-object v2

    invoke-virtual {v2}, Lcom/tendcloud/tenddata/cr$a;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v2

    const-string v3, "insert into msg values(?,?)"

    const/4 v4, 0x2

    new-array v4, v4, [Ljava/lang/Object;

    const/4 v5, 0x0

    aput-object p0, v4, v5

    const/4 v5, 0x1

    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v6

    invoke-static {v6, v7}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v6

    aput-object v6, v4, v5

    invoke-virtual {v2, v3, v4}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;[Ljava/lang/Object;)V
    :try_end_0
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_0

    :goto_0
    return v0

    :catch_0
    move-exception v0

    const-string v2, "PushLog"

    invoke-virtual {v0}, Ljava/lang/Throwable;->getMessage()Ljava/lang/String;

    move-result-object v0

    invoke-static {v2, v0}, Lcom/tendcloud/tenddata/cs;->e(Ljava/lang/String;Ljava/lang/String;)V

    :cond_1
    move v0, v1

    goto :goto_0
.end method

.method static i(Ljava/lang/String;)Z
    .locals 6

    const/4 v0, 0x1

    const/4 v1, 0x0

    invoke-static {p0}, Lcom/tendcloud/tenddata/cp;->a(Ljava/lang/String;)Z

    move-result v2

    if-eqz v2, :cond_0

    :goto_0
    return v0

    :cond_0
    :try_start_0
    invoke-static {}, Lcom/tendcloud/tenddata/cr;->d()Lcom/tendcloud/tenddata/cr$a;

    move-result-object v0

    invoke-virtual {v0}, Lcom/tendcloud/tenddata/cr$a;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    const-string v2, "select ct from msg where msg_id=?"

    const/4 v3, 0x1

    new-array v3, v3, [Ljava/lang/String;

    const/4 v4, 0x0

    aput-object p0, v3, v4

    invoke-virtual {v0, v2, v3}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v2

    invoke-interface {v2}, Landroid/database/Cursor;->moveToFirst()Z
    :try_end_0
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_1

    move-result v0

    :try_start_1
    invoke-interface {v2}, Landroid/database/Cursor;->close()V
    :try_end_1
    .catch Ljava/lang/Throwable; {:try_start_1 .. :try_end_1} :catch_0

    goto :goto_0

    :catch_0
    move-exception v1

    :goto_1
    const-string v2, "PushLog"

    invoke-virtual {v1}, Ljava/lang/Throwable;->getMessage()Ljava/lang/String;

    move-result-object v1

    invoke-static {v2, v1}, Lcom/tendcloud/tenddata/cs;->e(Ljava/lang/String;Ljava/lang/String;)V

    goto :goto_0

    :catch_1
    move-exception v0

    move-object v5, v0

    move v0, v1

    move-object v1, v5

    goto :goto_1
.end method
